package com.springboot.controller;

import com.springboot.entity.Member;
import com.springboot.result.Result;
import com.springboot.service.IMemberService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/member")
public class MemberController {
    @Autowired
    private IMemberService iMemberService;

    @GetMapping("/list")
    public List<Member> findAll() {
        return iMemberService.findAll();
    }

    @PostMapping("/add")
    public Result<?> add(@RequestBody Member member) {
        return iMemberService.add(member);
    }

    @PostMapping("/updateById")
    public Result<Integer> updateById(@RequestBody Member member) {
        return iMemberService.updateById(member);
    }

    @GetMapping("/get/{id}")
    public Result<Member> findById(@PathVariable("id") Integer id) {
        return iMemberService.findById(id);
    }

}
